<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="modal-dialog x-modal-dialog" style="width: 600px;margin-top: 150px;">

  <div class="modal-content">
  
    <div class="modal-header x-breadcrumb clearfix">

      <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>编辑个人信息</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>
    
    <form class="form-horizontal" method="POST" action="${ctx.host}/principals/${principal.id}/profile" data-validate="true">

      <input type="hidden" name="_method" value="PATCH" >
      <input type="hidden" name="id" value="${principal.id}" >

      <div class="modal-body">
      
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">真实姓名：</label>
          <div class="pull-left col-xs-6">
            <input name="profile.realname" type="text" class="form-control" value="${principal.profile.realname}" data-validate="required">
          </div>
        </div>

        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">用户昵称：</label>
          <div class="pull-left col-xs-6">
            <input name="profile.nickname" type="text" class="form-control" value="${principal.profile.nickname}" data-validate="required">
          </div>
        </div>
        
        <div class="form-group">
          <label class="control-label col-xs-4">用户性别：</label>
          <div class="col-xs-6 pull-left">
            <select name="profile.gender"  class="form-control select2" data-validate="required">
              <c:forEach var="gender" items="${enums['gender']}">
                <c:if test="${gender.display}">
                  <option value="${gender}" ${principal.profile.gender eq gender ? 'selected' : ''}>${gender.description}</option>
                </c:if>
              </c:forEach>
            </select>
          </div>
        </div>
        
        <div class="form-group">
          <label class="control-label col-xs-4">用户擅长：</label>
          <div class="col-xs-6 pull-left">
            <input name="profile.specialty" type="text" class="form-control select2" value="${principal.profile.specialty}"  multiple data-validate="required">
            <%-- <textarea name="profile.specialty" rows="3" class="form-control" style="width: 100%;">${principal.profile.specialty}</textarea> --%>
          </div>
        </div>
        
        <div class="form-group">
          <label class="control-label col-xs-4">用户简介：</label>
          <div class="col-xs-6 pull-left">
            <textarea name="profile.description" rows="3" class="form-control" style="width: 100%;">${principal.profile.description}</textarea>
          </div>
        </div>
        
      </div>
      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>

    </form>
  </div>
</div>

<script type="text/javascript">
  $(function(){
    
    $('select[name="profile.sex"]').select2({
        placeholder : '用户性别',
        minimumResultsForSearch : -1,
        allowClear : true
    });
    $('input[name="profile.specialty"]').select2({
        placeholder: "可输入多个，输入英文逗号完成一个输入",
        tokenSeparators: [','],
        tags: true
      })
    
  })
</script>